package com.xiechuang.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 控制层
 * @Author xiechuang
 * @Date 2022/1/4
 */
@RestController
@RequestMapping("")
public class TestController {

    /**
     * 测试访问
     *
     * @return
     */
    @RequestMapping("/test")
    public String testHello() {
        return "test success：eureka-client04-demo";
    }

    /**
     * 测试hystrix dashboard
     */
    @RequestMapping("/testHystrixDashboard")
    @HystrixCommand(fallbackMethod = "hystrixDashboardError")
    public String testHystrixDashboard() {
        return "test success: testHystrixDashboard! service eureka04";
    }

    /**
     * 熔断器回调失败方法
     *
     * @return
     */
    public String hystrixDashboardError() {
        return "test fail: hystrixDashboardError";
    }

}
